package com.maket.scxx.feign;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

@Component
public class GetCodeFeign {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public String getUser(@PathVariable("id")Integer id){
        // 调用存储过程并注册输出参数
        Map<String, Object> outParams = new HashMap<>();
        outParams.put("generated_bill_number", Types.VARCHAR); // 注册输出参数

        // 执行存储过程
        jdbcTemplate.update("CALL generate_and_update_bill_number(?, @generated_bill_number)", id);

        // 获取输出参数的值
        String generatedBillNumber = jdbcTemplate.queryForObject("SELECT @generated_bill_number", String.class);

        return generatedBillNumber;
    }

}
